import Request from '@/utils/request'

export const fetchGrantedResources = (roleId) =>  {
    return Request({
        url: `/sys/role/hasGrantedResource/${roleId}`,
        method: 'get',
    })
}

export const fetchGrantedUsers = (roleId) =>  {
    return Request({
        url: `/sys/role/getGrantedUsers/${roleId}`,
        method: 'get',
    })
}

export const fetchUnGrantedUsers = (roleId) =>  {
    return Request({
        url: `/sys/role/getUnGrantedUsers/${roleId}`,
        method: 'get',
    })
}

export const grantResource = (data) => {
    return Request({
        url: '/sys/role/grantResource',
        method: 'post',
        data: data
    })
}
export const grantToUser = (data) => {
    return Request({
        url: '/sys/role/grantToUser',
        method: 'post',
        data: data
    })
}

export const rolePage = (data) => {
    return Request({
        url: '/sys/role/rolePage',
        method: 'post',
        data: data
    })
}


export const saveRole = (data) => {
    return Request({
        url: '/sys/role/saveRole',
        method: 'post',
        data: data
    })
}

export const editRole = (data) => {
    return Request({
        url: '/sys/role/editRole',
        method: 'post',
        data: data
    })
}

export const roleOne = (roleId) => {
    return Request({
        url: `/sys/role/roleOne/${roleId}`,
        method: 'get'
    })
}
export const deleteRole = (roleId) => {
    return Request({
        url: `/sys/role/deleteRole/${roleId}`,
        method: 'get'
    })
}
